import request from './request';
import { userStores } from '@/stores';
// 登录
export const login = async (data = {}) => {
	return await request.post('/api/manday/pc/login', data).then((res: any) => {
		return res;
	});
};
// 获取个人信息
export const getMyUserInfo = async (data = {}) => {
	return await request.get('/api/manday/pc/userinfo', data).then((res: any) => {
		const store = userStores();
		store.user.userInfo = res.data;
		return res;
	});
};
// 修改个人信息
export const updateUserInfo = async (data = {}) => {
	return await request.post('/api/manday/pc/updateinfo', data).then((res: any) => {
		return res;
	});
};

// 修改密码
export const updateUserpwd = async (data = {}) => {
	return await request.post('/api/manday/pc/updatepwd', data).then((res: any) => {
		return res;
	});
};
// 获取小程序用户
export const getAppUsers = async (data = {}) => {
	return await request.get('/api/manday/pc/appusers', data).then((res: any) => {
		return res;
	});
};
// 获取管理系统用户
export const getPcUsers = async (data = {}) => {
	return await request.get('/api/manday/pc/userlist', data).then((res: any) => {
		return res;
	});
};

// 管理系统新增用户
export const addPcUsers = async (data = {}) => {
	return await request.post('/api/manday/pc/addpcuser', data).then((res: any) => {
		return res;
	});
};
// 管理系统设置是否禁止登录
export const pcForbidden = async (id: number | string) => {
	return await request.get(`/api/manday/pc/forbiddenuser/${id}`).then((res: any) => {
		return res;
	});
};
// 管理系统设置是否管理员
export const pcIsAdmin = async (id: number | string) => {
	return await request.get(`/api/manday/pc/isadmin/${id}`).then((res: any) => {
		return res;
	});
};
// 删除用户
export const deleteUser = async (id: number | string) => {
	return await request.get(`/api/manday/pc/deleteuser/${id}`).then((res: any) => {
		return res;
	});
};
// 获取用户反馈列表
export const getFeedbacklist = async (data = {}) => {
	return await request.get('/api/manday/pc/feedback', data).then((res: any) => {
		return res;
	});
};
// 获取消息列表
export const getMessage = async (data = {}) => {
	return await request.get('/api/manday/pc/messagelist', data).then((res: any) => {
		return res;
	});
};
// 发布消息
export const postMessage = async (data = {}) => {
	return await request.post('/api/manday/pc/messages', data).then((res: any) => {
		return res;
	});
};

// 首页图表数据
export const getEcharts = async (day: number | string) => {
	return await request.get(`/api/manday/pc/newuserincrement/${day}`).then((res: any) => {
		return res;
	});
};
// 获取app菜单
export const getAppMenus = async (data = {}) => {
	return await request.get('/api/manday/pu/indexall', data).then((res: any) => {
		return res;
	});
};
// 获取单个app菜单
export const getAppMenuOne = async (menuid: number | string) => {
	return await request.get(`/api/manday/pu/menu/${menuid}`).then((res: any) => {
		return res;
	});
};
// 修改单个app菜单
export const updateMenu = async (data = {}) => {
	return await request.post('/api/manday/pu/menu', data).then((res: any) => {
		return res;
	});
};
// 新增单个app菜单
export const addMenu = async (data = {}) => {
	return await request.post('/api/manday/pu/newmenu', data).then((res: any) => {
		return res;
	});
};
// 删除单个app菜单
export const deleteMenuOne = async (menuid: number | string) => {
	return await request.get(`/api/manday/pu/deletemenu/${menuid}`).then((res: any) => {
		return res;
	});
};
// 获取信息采集配置
export const getMsgConfig = async () => {
	return await request.get('/api/manday/pu/pcconfig').then((res: any) => {
		return res;
	});
};
// 修改信息采集配置
export const updateMsgConfig = async (data = {}) => {
	return await request.post('/api/manday/pu/updatepcconfig', data).then((res: any) => {
		return res;
	});
};
// 删除消息列表
export const deletMsg = async (data = {}) => {
	return await request.post('/api/manday/pc/deletemessages', data).then((res: any) => {
		return res;
	});
};
// 查询反馈详情
export const getFeedbackDetails = async (id: number | string) => {
	return await request.get(`/api/manday/pc/feedbackdetails/${id}`).then((res: any) => {
		return res;
	});
};
// 查询反馈详情
export const getUserdetails = async (data = {}) => {
	return await request.get(`/api/manday/pc/userdetails`, data).then((res: any) => {
		return res;
	});
};
// 退出登录
export const outLogin = async () => {
	return await request.get('/api/manday/pc/outlogin').then((res: any) => {
		return res;
	});
};
